package cn.kgc.spring.basic;

import cn.kgc.spring.basic.factory.NewBeanFactory;

/**
 * @author: mosin
 * @version: v1.0  2022/6/29
 */
public class UserServiceImpl implements UserService {

    // new 创建对象  硬编码  不利于代码的维护   耦合性高
    //private  UserMapper userMapper = BeanFactory.getUserMapperImpl();

    //private  UserMapper userMapper = (UserMapper)NewBeanFactory.getBean("userMapper");

    private  UserMapper userMapper = NewBeanFactory.getBean("userMapper",UserMapper.class);

    @Override
    public Boolean login(User user) {
        User usr = userMapper.selectByUser(user);
        return usr==null;
    }

    @Override
    public Boolean register(User user) {
        Integer line = userMapper.addUser(user);
        return line>0;
    }
}
